<?php
namespace app\api\validate;

use think\Validate;

class Entrust extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'id'         => 'require|number',
        'all_no'     => 'require|regex:\w{3,30}',
        'num'        => 'require|regex:[1-9]\d*00',
        'isAuto'     => 'require',
        'deal_price' => 'require|number|gt:0',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'all_no.require' => '股票编号不能为空',
        'num.regex'     => '数量必须为100的倍数',
        'isAuto.require'=> '请选择是否自动管理',
        'deal_price.number' => '购买的价格必须是一个数字',
        'deal_price.gt'      => '购买价格需大于0'
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'create'   => ['all_no','num','isAuto','deal_price'],
        'cancel'   => ['id','num'],
        'deal'     => ['id','num'],
    ];
    
}
